<template>
	<div>
		<el-table :data="showData" style="width: 100%">
			<el-table-column prop="id" label="id" width="180">
			</el-table-column>
			<el-table-column prop="agent.name" label="代理名称" width="150">
			</el-table-column>
			<el-table-column prop="money" align="center" label="提现金额">
			</el-table-column>
			<el-table-column prop="note" align="center" label="备注">
			</el-table-column>
			<el-table-column prop="status" label="提现状态">
				<template slot-scope="scope">
					<span v-if="scope.row.status === 0">待打款</span>
					<span v-else-if="scope.row.status === 1">已打款</span>
					<span v-else>无</span>
				</template>
			</el-table-column>
			<el-table-column prop="update_time" label="时间">
			</el-table-column>
		</el-table>
		<div class="whole-pagination">
			<el-pagination background layout="prev, pager, next" :total="count" @current-change="changePage">
			</el-pagination>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				agentID: this.$store.state.userId ? this.$store.state.userId : JSON.parse(window.localStorage.userInfo).userId,
				limit: 10,
				count: 0,
				showData: []
			}
		},
		created() {
			this.getData(1);
		},
		methods: {
			getData(page) {
				let that = this;
				that.$axios({
					url: '/admin/agent/getDrawal',
					method: 'POST',
					data: {
						agentID: that.agentID,
						offset: page,
						limit: that.limit,
					},
					success(res) {
						if (res.data.code == 200) {
							that.showData = res.data.content.data;
							that.count = res.data.content.count;
						} else {
							that.$message(res.data.msg);
						}
					}
				});
			},
			changePage(page) {
				this.getData(page);
			}
		}
	}
</script>
